package com.jumptap.adtag.utils;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.util.Log;
import com.jumptap.adtag.JtAdWidgetSettings;

public class JtSettingsParameters
{
  private static final String ADULT_CONTENT_TYPE = "adultContentType";
  private static final String AGE = "age";
  private static final String ALTERNATE_IMAGE = "alternateImage";
  private static final String APP_ID = "applicationId";
  private static final String APP_VER = "applicationVersion";
  private static final String BACKGROUND_COLOR = "alternateColor";
  private static final String COUNTRY = "country";
  private static final String DISMIIS_BUTTON_LABEL = "dismissLabel";
  private static final String GENDER = "gender";
  private static final String HHI = "hhi";
  private static final String HOST = "host";
  private static final String INTERDTITIAL_TIME = "interstitialTime";
  private static final String LANGUAGE = "language";
  private static final String POSTAL_CODE = "postalCode";
  private static final String PUBLISHER_ID = "publisherId";
  private static final String REFRESH_PERIOD = "refreshPeriodInSec";
  private static final String SITE_ID = "siteId";
  private static final String SPOT_ID = "spotId";

  public static int getIntValueFromAttributes(AttributeSet paramAttributeSet, String paramString1, String paramString2)
  {
    int i = -1;
    if (paramAttributeSet != null)
      i = paramAttributeSet.getAttributeIntValue(paramString1, paramString2, -1);
    return i;
  }

  public static String getStringValueFromAttributes(AttributeSet paramAttributeSet, String paramString1, String paramString2)
  {
    if (paramAttributeSet != null)
    {
      String str = paramAttributeSet.getAttributeValue(paramString1, paramString2);
      if ((str != null) && (!str.equalsIgnoreCase("")) && (str.length() > 0))
        return str;
    }
    return null;
  }

  public static int getUnsignedIntValueFromAttributes(AttributeSet paramAttributeSet, String paramString1, String paramString2)
  {
    int i = -1;
    if (paramAttributeSet != null)
      i = paramAttributeSet.getAttributeUnsignedIntValue(paramString1, paramString2, -1);
    return i;
  }

  public static void populateSettings(JtAdWidgetSettings paramJtAdWidgetSettings, AttributeSet paramAttributeSet, Context paramContext)
  {
    String str1 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "publisherId");
    if (str1 != null)
      paramJtAdWidgetSettings.setPublisherId(str1);
    String str2 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "siteId");
    if (str2 != null)
      paramJtAdWidgetSettings.setSiteId(str2);
    String str3 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "spotId");
    if (str3 != null)
      paramJtAdWidgetSettings.setSpotId(str3);
    String str4 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "host");
    if (str4 != null)
      paramJtAdWidgetSettings.setHostURL(str4);
    String str5 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "language");
    if (str5 != null)
      paramJtAdWidgetSettings.setLanguage(str5);
    String str6 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "adultContentType");
    if (str6 != null)
      paramJtAdWidgetSettings.setAdultContentType(str6);
    String str7 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "postalCode");
    if (str7 != null)
      paramJtAdWidgetSettings.setPostalCode(str7);
    String str8 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "country");
    if (str8 != null)
      paramJtAdWidgetSettings.setCountry(str8);
    String str9 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "age");
    if (str9 != null)
      paramJtAdWidgetSettings.setAge(str9);
    String str10 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "gender");
    if (str10 != null)
      paramJtAdWidgetSettings.setGender(str10);
    String str11 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "hhi");
    if (str11 != null)
      paramJtAdWidgetSettings.setHHI(str11);
    String str12 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "alternateImage");
    if (str12 != null)
      setAlternativeImage(str12, paramJtAdWidgetSettings, paramContext);
    String str13 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "dismissLabel");
    if (str13 != null)
      paramJtAdWidgetSettings.setDismissButtonLabel(str13);
    int i = getUnsignedIntValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "alternateColor");
    if (i != -1)
      paramJtAdWidgetSettings.setBackgroundColor(i);
    int j = getIntValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "refreshPeriodInSec");
    if (j != -1)
      paramJtAdWidgetSettings.setRefreshPeriod(j);
    int k = getIntValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "interstitialTime");
    if (k != -1)
      paramJtAdWidgetSettings.setInterstitialshowTime(k);
    String str14 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "applicationId");
    if (str14 != null)
      paramJtAdWidgetSettings.setApplicationId(str14);
    String str15 = getStringValueFromAttributes(paramAttributeSet, "http://www.jumptap.com/lib/android", "applicationVersion");
    if (str15 != null)
      paramJtAdWidgetSettings.setApplicationVersion(str15);
  }

  private static void setAlternativeImage(String paramString, JtAdWidgetSettings paramJtAdWidgetSettings, Context paramContext)
  {
    Resources localResources = paramContext.getResources();
    String str = paramContext.getPackageName();
    Log.d("JtAd", "Here is the parameter: " + paramString + " defaultPackage: " + str);
    int i = localResources.getIdentifier(paramString, null, str);
    if (i != 0)
      try
      {
        paramJtAdWidgetSettings.setAlternateImage(((BitmapDrawable)localResources.getDrawable(i)).getBitmap());
        return;
      }
      catch (Resources.NotFoundException localNotFoundException)
      {
        Log.e("JtAd", "Cannot found Resource:" + paramString + ". Going to load system alternative image");
        Log.e("JtAd", localNotFoundException.getMessage());
        return;
      }
    Log.e("JtAd", "Cannot found Resource:" + paramString);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.jumptap.adtag.utils.JtSettingsParameters
 * JD-Core Version:    0.6.2
 */